package com.strutor.stack;


import com.strutor.linked.BaseLinked;

public class LinkedStack<E> implements BaseStack<E> {
    private BaseLinked<E> list;

    public LinkedStack(){
        list = new BaseLinked<>();
    }

    @Override
    public int getSize() {
        return list.getSize();
    }

    @Override
    public boolean isEmpty() {
        return list.isEmpty();
    }

    @Override
    public void push(E e) {
        list.addFirst(e);
    }

    @Override
    public E pop() {
        return list.removeFirst();
    }

    @Override
    public E peek() {
        return list.getFirst();
    }

    @Override
    public String toString() {
        StringBuilder ret = new StringBuilder();
        ret.append("Stack:top");
        ret.append(list);
        return ret.toString();
    }
}
